#include<bits/stdc++.h>
using namespace std;
#define LN int(1e6+5)
#define ll long long
ll T,n,m,L,V;
ll d[LN]={0},v[LN]={0},a[LN]={0},p[LN]={0};
int zt[3005]={0};
ll hx[LN]={0};
ll build(int x,int y){
    ll ans=0;
    for(ll i=1;i<=x;i++){
        ll sd=v[i];
        ll dq=d[i];
        ll bj=0;
        for(ll q=1;q<=y;q++){
            if(p[q]>=dq){
                bj=q;
                break;
            }
        }
        if(bj==0){
            zt[i]=0;
            continue;
        }
        //cout<<"i:"<<i<<" sd:"<<sd<<" dq:"<<dq<<" bj:"<<bj<<endl;
        for(;;){
            if(hx[p[bj]]==1){
                //cout<<"BCTG:"<<p[bj]<<endl;
                bj++;
            }
            else{
                ll wy=p[bj]-dq;
                if(dq==L){
                    break;
                }
                ll vq=int(sqrt((2*a[i]*(wy))+(sd*sd)));
                //cout<<" dq:"<<dq<<" vq:"<<vq<<endl;
                if(vq>V){
                    zt[i]++;
                }
                sd=vq;
                if(p[bj]!=0) dq=p[bj];
                else break;
                bj++;
            }
        }
        if(zt[i]!=0) ans++;
    }
    return ans;
}
ll jg=0;
void gb(ll benlai,ll righ,ll whic,ll deep){
    //cout<<"benlai:"<<benlai<<" righ:"<<righ<<" which:"<<whic<<" deep:"<<deep<<endl;
    if(whic>righ){
        if(deep-1>jg){
            jg=deep-1;
        }
        return ;
    }
    else{
        hx[p[whic]]=1;
        if(build(n,m)==benlai){
            gb(benlai,righ,whic+1,deep+1);
            hx[p[whic]]=0;
        }
        else{
            hx[p[whic]]=0;
            gb(benlai,righ,whic+1,deep);
        }
    }
    return ;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(ll i=1;i<=T;i++){
        for(int r=0;r<=3005;r++){
            d[r]=0;
            v[r]=0;
            a[r]=0;
            p[r]=0;
            hx[r]=0;
        }
        cin>>n>>m>>L>>V;
        for(ll j=1;j<=n;j++){
            cin>>d[j]>>v[j]>>a[j];
        }
        for(ll j=1;j<=m;j++){
            cin>>p[j];
        }
        ll zg=build(n,m);
        if(zg==0) cout<<zg<<" "<<m<<endl;
        else {
            gb(zg,m,1,0);
            cout<<zg<<" "<<jg<<endl;
        }
        /*for(ll j=1;j<=n;j++){
            cout<<" j:"<<j<<" zt:"<<zt[j]<<endl;
        }
        */
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}